import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

/**
 * @Classname Main
 * @Description TODO
 * @Date 2021/9/18 16:34
 * @Created by ASUS
 */
public class Main {
    public static void main(String[] args) {
        map.put(']','[');
        map.put(')','(');
        map.put('}','{');
        isVailed("{{{[[[");
    }

    static Map<Character, Character> map = new HashMap<>();

    public static boolean isVailed(String str) {
        if (str == null) return false;
        if ("".equals(str)) return true;
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '(' || str.charAt(i) == '[' || str.charAt(i) == '{') stack.push(str.charAt(i));
            else {
                if (stack.isEmpty()) return false;
                Character peek = stack.peek();
                if (map.get(peek) == str.charAt(i)) stack.pop();
            }
        }
        return stack.isEmpty();
    }
}
